from urllib import request,parse
from http import cookiejar

cookie = cookiejar.CookieJar()
cookie_handler = request.HTTPCookieProcessor(cookie)
http_handler = request.HTTPHandler()
https_handler = request.HTTPSHandler()
opener = request.build_opener(cookie_handler)


base_url = 'https://i.qq.com/?rd=1'
def dl(msg,password):
    data = {
        'email':msg,
        'password':password
    }
    newdata = parse.urlencode(data)

    req = request.Request(url=base_url,data=bytes(newdata,encoding='utf-8'))

    response = opener.open(req)

    home = 'https://user.qzone.qq.com/1376906157'

    home_response = opener.open(home)

    html = response.read().decode('utf-8')

    with open('./qq.html','w',encoding='utf-8') as f:
        f.write(html)
    print(html)

if __name__ == '__main__':
    msg = input('请输入账户:')
    password = input('请输入密码:')
    dl(msg,password)